package com.jh.utils;

import com.jh.dto.EmployeeDTO;
import com.jh.entity.Employee;
import org.springframework.beans.BeanUtils;

//员工工具类
public class EmployeeUtil {
    public static Employee convertToEmployee(EmployeeDTO employeeDTO) {
        Employee employee = new Employee();
        BeanUtils.copyProperties(employeeDTO, employee);

        switch (employeeDTO.getPosition()) {
            case "店长":
                employee.setPosition(1);
                break;
            case "店员":
                employee.setPosition(0);
                break;
            default:
                throw new IllegalArgumentException("未知的职位: " + employeeDTO.getPosition());
        }

        return employee;
    }
}
